<template>	
	<view class="content">
		<u-navbar :is-back="true" :title="title" title-color="white" :background="background"></u-navbar>
		<swiper autoplay interval="3000" circular class="goods_pic">
		    <block v-for='(item,index) in goods_detail.urls' :key='index'>
		        <swiper-item>
		            <image  :src="baseimg_url + item" mode="aspectFit" class="goods_pic" @click="showgoods(index)"></image>
		        </swiper-item>
		    </block>
		</swiper>
		<view class="top">
			<view class="title">{{goods_detail.name}}</view>
			<view class="date">时间:{{goods_detail.gmtCreate}}</view>
			
		</view>
		<view class="desc">
			地点：{{goods_detail.location}}
			
		</view>
		<view class="desc">
			内容：{{goods_detail.description}}
			
		</view>
		<view class="concat">
			<view class="c-item wechat" >
				<view>微信号：{{my_phone}}</view>
				<button @click="copyWechat" class="c-btn">复制微信</button>
			</view>
			<!-- <view class="c-item mobile">
				<view>手机号：{{my_phone}}</view>
				<button @click="call" class="c-btn">拨打电话</button>
			</view> -->
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:"物品详情",
				background:{
					backgroundImage:'linear-gradient(to top, #ffd655 0%, #fda085 100%)',
				},
				baseimg_url:this.baseimgUrl,
				goods_detail:[],
				my_phone:"",
			}
		},
		onLoad(paramas) {
			var me = this;
			var globalUser = me.getGlobalUser("globalUser");
			me.globalUser = globalUser;
			var phone = me.globalUser.user.city;
			me.my_phone = phone;
			me.id = paramas.id;
			me.getgoods_detail();
			//me.pageView();
		},
		methods: {
			getgoods_detail(){
				var me = this;
				console.log(me.id)
				uni.request({
					url:me.baseUrl + "/mini_program/res/getRes/" + me.id,
					method: 'GET',
					success: res => {
						/* debugger */
						me.goods_detail = res.data.data.res;
					}
				})
			},
			showgoods(index){
				var me = this,imgs = me.goods_detail.urls,faceArr = [];
				for(var i = 0 ; i<imgs.length;i++){
					faceArr.push(me.baseimg_url + imgs[i]);
				}
				/* debugger */
				uni.previewImage({
					urls:faceArr, 
					current:index
				})
			},
			call() {
			    uni.makePhoneCall({
			        phoneNumber: this.my_phone
			    });
			},
			
			copyWechat() {
			    uni.setClipboardData({
			        data: this.my_phone,
			        success: () => {
			            uni.showToast({
			                title: '复制微信号成功'
			            });
			        }
			    });
			},
			pageView(){
				var me =this;
				uni.request({
					url:me.baseUrl + "/mini_program/page-view/add",
					method: 'POST',
					success: res => {
						console.log(res.data.data)
						
					}
				})
			}
			
			
		}
	}
</script>

<style>
.content {
    width: 100%;
    box-sizing: border-box;
    padding: 40rpx;
}

.goods_pic {
	width: 100%;
	height: 440upx;
}

.top {
    margin-top: 10rpx;
    height: 80rpx;
    display: flex;
    position: relative;
    align-items: baseline;
}

.title {
    font-size: 38rpx;
    font-weight: 600;
    margin-right: 20rpx;
}

.date {
    font-size: 24rpx;
    color: #bbb;
}

.desc {
    font-size: 28rpx;
    /* text-indent: 56rpx; */
}

.concat {
    box-sizing: border-box;
    padding: 40rpx;
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    display: flex;
    flex-wrap: wrap;
}

.c-item {
    font-size: 28rpx;
    width: 100%;
    height: 80rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* border-bottom: 2rpx solid #fdb92c; */
}

.c-item view {
    width: 100%;
}

.c-item button.c-btn {
    padding: 0;
    font-size: 24rpx;
    height: 55rpx;
    width: 200rpx;
    line-height: 55rpx;
    text-align: center;
    font-weight: 600;
    border-radius: 6rpx;
    background-color: #fdb92c;
}

.c-item button.c-btn::after {
    border: none;
}
</style>
